package com.yaoli.ajob;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by will on 2017/4/27.
 */
public class _442_FindAllDuplicatesinanArray {
    public List<Integer> findDuplicates(int[] nums) {
        int [] set = new int [nums.length];

        for(int i = 0 ; i < nums.length ; i ++){
            int temp = nums[i];

            set[temp - 1]++;
        }

        List<Integer> list = new ArrayList<Integer>();

        for(int i = 0 ; i < set.length ; i++){
            if(set[i] == 2){
                list.add(i+1);
            }
        }

        return list;
    }
}
